package pl.fiszkiapp.tutorial;

import pl.example.fiszkiapp.R;
import pl.example.fiszkiapp.R.drawable;
import pl.example.fiszkiapp.R.id;
import pl.example.fiszkiapp.R.layout;
import pl.example.fiszkiapp.R.string;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
/**
 * Okienko wywietlajce pojedynczy temat pomocy.
 * @author Piotr Czerwiec
 */
public class LessonActivity extends Activity {
	public short helpIndex = 0;
	public TextView helpText;
	public ImageView picture;
	
	public int [] pics = {R.drawable.xml,
			
			R.drawable.xml,
			R.drawable.tryby_gry,
			R.drawable.zgadywanie_hasel,
			
			R.drawable.zgadywanie_opisow,
			R.drawable.wybor_testu,
			R.drawable.xml,
			
			R.drawable.xml,
			R.drawable.xml,
			R.drawable.xml};
	
	public int [] texts = {R.string.xml,
			R.string.nagrywanie_testu,
			R.string.tryb_rozgrywki,
			
			R.string.zgadywanie_hasel,
			R.string.zgadywanie_opisow,
			R.string.wybor_testu,
			
			R.string.zarzadzanie_fiszki,
			R.string.edycja_hasel,
			R.string.dodawanie_zdjec,
			
			R.string.wybieranie_zdjecia};	
	
	public void onCreate(Bundle savedInstance){
		super.onCreate(savedInstance);
		this.setContentView(R.layout.help_layout);			
		Bundle extras = getIntent().getExtras();
				
		helpIndex = extras.getShort("num");
		Resources resources = this.getResources();
		
		helpText = new TextView(this);
		helpText = (TextView) findViewById(R.id.tekst_pomocy);
		helpText.setText(resources.getString(texts[helpIndex]));
		helpText.setMovementMethod(new ScrollingMovementMethod());
		picture = new ImageView(this);
		picture = (ImageView) findViewById(R.id.obrazek_pomocniczy);
		picture.setBackgroundDrawable(resources.getDrawable(pics[helpIndex]));
		
	}
	/**
	 * Obsluga nacisniecia przycisku nastepny.
	 * @param v
	 */
	public void nextTopic(View v) {
		if (helpIndex < texts.length - 1) {
			helpIndex++;
			Resources resources = this.getResources();
			helpText.setText(resources.getString(texts[helpIndex]));
			picture.setBackgroundDrawable(resources.getDrawable(pics[helpIndex]));
		}
	}
	/**
	 * Obsluga nacisniecia przycisku poprzedni.
	 * @param v
	 */
	public void previousTopic(View v) {
		if (helpIndex > 0) {
			helpIndex--;
			Resources resources = this.getResources();
			helpText.setText(resources.getString(texts[helpIndex]));
			picture.setBackgroundDrawable(resources.getDrawable(pics[helpIndex]));
		}
	}
}
